package iscte.ai.kcgtd;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class EventsViewAdapter extends BaseAdapter {

	private Activity activity;
	private ArrayList<OccupiedBlocks> events;

	public EventsViewAdapter(Activity activity, ArrayList<OccupiedBlocks> events) {
		this.activity = activity;
		this.events = events;
	}

	@Override
	public int getCount() {
		return events.size();
	}

	@Override
	public Object getItem(int position) {
		return events.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View view, ViewGroup arg2) {
		LayoutInflater inflator = activity.getLayoutInflater();
		view = inflator.inflate(R.layout.task_item, null);

		TextView name = (TextView) view.findViewById(R.id.task_item_name);
		name.setText(events.get(position).getEventName());
		
		TextView Date = (TextView) view.findViewById(R.id.task_item_date);
		Date.setText(events.get(position).getStartTime() + " - " + events.get(position).getEndTime());

		return view;
	}
	
}
